<%-- 
    Document   : insert_artikel
    Created on : Jan 11, 2014, 3:31:12 PM
    Author     : brlnt
--%>

<%@page import="model.ArtikelBean"%>
<%@include file="../template/header.jsp"%>
<script type="text/javascript" src="${initParam.js}/tinymce/js/tinymce/tinymce.min.js"></script>
<script src="${initParam.js}/parsley.js"></script>
<script src="${initParam.js}/parsley.extend.js"></script>
<script type="text/javascript">
    tinymce.init({
        mode: "exact",
        elements: "isi",
        add_unload_trigger: false,
        entities: 'raw',
        valid_styles: {
            '*': 'color,font-size,font-family,background-color,font-weight,font-style,text-decoration,float,margin,margin-top,margin-right,margin-bottom,margin-left,display'
        }
    });
</script>
<%
    ArtikelBean dataArtikel = (ArtikelBean) request.getAttribute("dataArtikel");
    String action = (String) request.getAttribute("action");
%>
<div class="row">
    <div class="col-lg-6 col-lg-push-1">
        <h3>${title}</h3>
        <hr>
        <fieldset>
            <form name="artikel" id="artikel" method="post" parsley-validate novalidate>
                <div class="form-group">
                    <input type="text" class="form-control" name="judul" placeholder="Judul" value="<%if(action.equals("Perbarui")){out.print(dataArtikel.getJudul());}%>" parsley-required="true">
                </div>
                <div class="form-group">
                    <textarea id="isi" class="form-control" name="isi"><%if(action.equals("Perbarui")){out.print(dataArtikel.getIsiArtilkel());}%></textarea>
                </div>
                <%if(action.equals("Perbarui")){ %>
                    <input type="hidden" name="id" value="<%=dataArtikel.getIdArtikel()%>">
                <%}%>
                <div class="form-group form-inline">
                    <!-- input type="submit" value="${action}" class="btn btn-primary" -->
                    <input type="submit" value="${action}" onclick="submitForm('${alamat}')" class="btn btn-primary"/>
                    <input type="submit" value="Simpan" onclick="submitForm('./simpan_artikel')" class="btn btn-danger"/>
                </div>
        </fieldset>
        </form>
    </div>
</div>
<script>
    function submitForm(action){
        document.getElementById('artikel').action = action;
        document.getElementById('artikel').submit();
    }
</script>
<%@include file="../template/footer.jsp"%>